/**
 * Copyright (c) 2013 Axa Holding Belgium, SA. All rights reserved.
 * This software is the confidential and proprietary information of the AXA Group.
 */
package chabernac.android.chargemybattery.actions;

import android.content.Context;
import android.net.wifi.WifiManager;

public class TurnOffWifiAction extends AbstractPowerSaveAction {
    private final WifiManager wifiManager;
    private boolean           isWifiCurrentlyEnabled;

    public TurnOffWifiAction( Context aContext ) {
        wifiManager = (WifiManager) aContext.getSystemService( Context.WIFI_SERVICE );
    }

    @Override
    public void executeAction() {
        isWifiCurrentlyEnabled = wifiManager.isWifiEnabled();
        wifiManager.setWifiEnabled( false );
    }

    @Override
    public void undo() {
        wifiManager.setWifiEnabled( isWifiCurrentlyEnabled );
    }

    @Override
    public boolean isComplete() {
        return !wifiManager.isWifiEnabled();
    }

}
